<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">会员卡</span>
      <span @click="showBeautyBox = true">组件美化</span>
    </div>
    <div class="control-body add-foot-bottom">
      <div class="control-section">
        <!-- 是否显示 -->
        <showModuleControl
          title="是否显示"
          :params="params"
          @reset="resetItem('showModule')"
        ></showModuleControl>
        <!-- 购买前内容 -->
        <div class="control-item">
          <div class="control-title">
            <span>购买前内容</span>
            <span class="reset" @click="resetItem('beforeBuyText')">重置</span>
          </div>
          <div class="control-content">
            <div class="textarea-box">
              <a-textarea
                v-model="params.params.beforeBuyText"
                placeholder="请输入购买前内容文案"
                :rows="4"
              />
            </div>
          </div>
        </div>
        <!-- 购买后内容 -->
        <div class="control-item">
          <div class="control-title">
            <span>购买后内容</span>
            <span class="reset" @click="resetItem('afterBuyText')">重置</span>
          </div>
          <div class="control-content">
            <div class="textarea-box">
              <a-textarea
                v-model="params.params.afterBuyText"
                placeholder="请输入购买后内容文案"
                :rows="4"
              />
            </div>
          </div>
        </div>
        <!-- 填充背景 -->
        <div class="bg-header">
          <span>填充背景</span>
          <span class="reset" @click="resetItem('memberCardCss')">重置</span>
        </div>
        <bgControl
          :showHeader="false"
          :backgroudData="params.params.memberCardCss"
          sizeText="750*110"
        ></bgControl>
        <!-- 添加连接 -->
        <div class="bg-header add-padding-bottom">
          <span>添加链接</span>
          <span class="reset" @click="resetItem('memberCardLink')">重置</span>
        </div>
        <chooseLink
          :link="params.params.memberCardLink"
          @chooseEnd="chooseLink"
        ></chooseLink>
      </div>
    </div>

    <!-- 组件美化 -->
    <comBeautyBox
      :showBeautyBox="showBeautyBox"
      @handleBack="showBeautyBox = false"
    >
      <div>
        <!-- 间距控制组件 -->
        <spaceControl
          :spaceData.sync="params.params.memberCardCss"
          :showMarginControl="false"
          @resetSpace="resetSpace"
          @resetMp="resetMp"
        ></spaceControl>
      </div>
    </comBeautyBox>
  </div>
</template>

<script>
import { userMember } from "@/components/DiyNew/diy/systemPages/userPage/dataConfig/config.js";
import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";
import comBeautyBox from "@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue";
import spaceControl from "@/components/DiyNew/diy/baseControl/spaceControl/index.vue";
import showModuleControl from "@/components/DiyNew/diy/baseControl/showModuleControl/index.vue";
import chooseLink from "@/components/DiyNew/chooseLink/index.vue";

export default {
  name: "userMemberCardControl",
  components: {
    bgControl,
    chooseLink,
    showModuleControl,
    comBeautyBox,
    spaceControl,
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showBeautyBox: false,
    };
  },
  watch: {},
  computed: {},
  mounted() {},
  methods: {
    uploadSuccess(e) {
      this.$setWithAction(this.params, "memberAdImg", e.val);
    },
    // 删除图片回调
    deleteImg(e) {
      this.$setWithAction(this.params, "memberAdImg", "");
    },
    resetItem(key) {
      let data = Object.assign({}, userMember);
      console.log(data.params[key]);
      this.$set(this.params.params, key, data.params[key]);
    },
    chooseLink(e) {
      this.$set(this.params.params, "memberCardLink", e);
    },
    // 重置圆角
    resetSpace(e) {
      let type = e.type;
      console.log(type);
      this.$set(this.params.params.memberCardCss, type, 0);
    },
    // 重置边距
    resetMp() {
      this.$set(this.params.params.memberCardCss, "padding", 0);
    },
  },
};
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .reset {
            font-size: 12px;
            font-weight: 400;
            color: #8e8e8e;
            cursor: pointer;
          }
        }
        .control-content {
          .textarea-box {
            width: 100%;
            ::v-deep .ant-input {
              width: 100%;
              background: #ffffff;
              background: #f6f7f9;
              border: 0 none;
              border-radius: 4px;
              resize: none;
            }
          }
        }
      }
      .bg-header {
        width: 100%;
        padding: 24px 0 0 0;
        font-size: 12px;
        color: #000000;
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
        .reset {
          font-size: 12px;
          font-weight: 400;
          color: #8e8e8e;
          cursor: pointer;
        }
      }
      .add-padding-bottom {
        padding-bottom: 14px;
      }
    }
  }
}
.add-foot-bottom {
  padding-bottom: 20px;
}
</style>
